package com.siki.www.clock.controller;


import com.siki.salessystemcommon.utils.SystemMsgJsonResponse;
import com.siki.www.clock.service.CityService;
import com.siki.www.clock.vo.CityInfoVO;
import com.siki.www.clock.vo.ProvincesAllInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author qizai
 */

@RestController
@Api(tags = "城市相关操作模块")
@RequestMapping("/api/vi/siki/city")
@CrossOrigin
public class CityController {
    private final CityService cityService;

    public CityController(CityService cityService) {
        this.cityService = cityService;
    }

    @GetMapping("/getAllProvinces")
    @ApiOperation(value = "获得所有省份",httpMethod = "GET",response = ProvincesAllInfoVO.class)
    public SystemMsgJsonResponse getAllProvinces(){
        return SystemMsgJsonResponse.success(cityService.getProvincesAll());
    }

    @GetMapping("/getCityByProvincesId/{provincesId}")
    @ApiOperation(value = "根据省份id获得城市",httpMethod ="GET",response = CityInfoVO.class)
    public SystemMsgJsonResponse getCity(@NotNull @ApiParam("省份id") @PathVariable("provincesId") Long provincesId){
        return SystemMsgJsonResponse.success(cityService.getCityByProvincesId(provincesId));
    }
}
